home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Technical Documentation / Sample Code / DTS.Lib & Samples / DTS.Lib / DTS.Lib.headers / GWLayers.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-22  |  6.9 KB  |  171 lines  |  [TEXT/MPS ]

  1. #ifndef __GWLAYERS__
  2. #define __GWLAYERS__
  3.  
  4. #ifndef __TYPES__
  5. #include "Types.h"
  6. #endif
  7.  
  8. #ifndef __MEMORY__
  9. #include <Memory.h>
  10. #endif
  11.  
  12. #ifndef __QDOFFSCREEN__
  13. #include <QDOffscreen.h>
  14. #endif
  15.  
  16. #ifndef __QUICKDRAW__
  17. #include <Quickdraw.h>
  18. #endif
  19.  
  20. struct LayerRec;
  21. typedef struct LayerRec *LayerRecPtr, **LayerObj;
  22.  
  23. typedef OSErr (*LayerProc)(LayerObj theLayer, short message);
  24.  
  25. typedef struct LayerRec {
  26.     LayerObj        aboveLayer;
  27.     LayerObj        belowLayer;
  28.     Boolean         layerOwnsPort;
  29.     GrafPtr            layerPort;
  30.     GDHandle        layerGDevice;
  31.     Handle            layerBitmap;
  32.     short            layerDepth;
  33.     LayerProc        layerProc;
  34.     unsigned long    layerData;
  35.     short            xferMode;
  36.     Rect            srcRect;
  37.     Rect            dstRect;
  38.     Rect            thisUpdate;
  39.     Rect            lastUpdate;
  40.     Boolean            includeLastUpdate;
  41.     Boolean            lockedCount;
  42.     Boolean            cachedCount;
  43.     CGrafPtr        cachedPort;
  44.     GDHandle        cachedGDevice;
  45. } LayerRec;
  46.  
  47. #define kLayerInit    0
  48. #define kLayerDispose 1
  49. #define kLayerUpdate  2
  50.  
  51. OSErr    NewLayer(LayerObj *newLayer, LayerObj aboveLayer, LayerProc theProc,
  52.                  GrafPtr basePort, short depth, unsigned long theData);
  53. /* Use this call to create a layer object.
  54. ** newLayer:     Layer object handle returned here.
  55. ** aboveLayer:   Layer object above this layer (if any) in the layer hierarchy. 
  56. ** theProc:      Layer definition procedure.  Use nil for default behaviors.
  57. ** basePort:     If the port or GWorld for the layer already exists, such as a window,
  58. **               pass it here.  If you want a GWorld created for you, pass in nil.
  59. ** theData:      Optional data reference.
  60. */
  61.  
  62. void    DetachLayer(LayerObj theLayer);
  63. /* Use this call to remove a layer from a layer hierarchy.  This call does
  64. ** not dispose of the layer. */
  65.  
  66. OSErr    DisposeLayer(LayerObj theLayer);
  67. /* Dispose of the layer.  If the layer belongs to a hierarchy, it is first
  68. ** removed from that hierarchy. */
  69.  
  70. OSErr    DisposeThisAndBelowLayers(LayerObj theLayer);
  71. /* Dispose of the layer and all layers below it in the hierarchy. */
  72.  
  73. short    GetLayerPosition(LayerObj theLayer);
  74. /* Return the layer position in the hierarchy.  0 is the top layer. */
  75.  
  76. LayerObj    GetTopLayer(LayerObj theLayer);
  77. /* Return the top layer in the hierarchy. */
  78.  
  79. LayerObj    GetBottomLayer(LayerObj theLayer);
  80. /* Return the bottom layer in the hierarchy. */
  81.  
  82. void    InsertLayer(LayerObj theLayer, LayerObj referenceLayer, short pos);
  83. /* Insert a layer into a hierarchy.  Passing a 0 for position makes the layer
  84. ** the top layer. */
  85.  
  86. OSErr    UpdateLayer(LayerObj theLayer);
  87. /* Given that a layer update has been posted, do the update.  LayerUpdate does
  88. ** a recursive update from theLayer down.  If there is a layer below, it calls
  89. ** LayerUpdate for that layer.  Once the bottom of the hierarchy is reached,
  90. ** the layerProc is called to do the update.  This causes the layer updates to
  91. ** occur from bottom up. */
  92.  
  93. Rect    UpdateUpdateRects(LayerObj theLayer);
  94. /* Return the rect that is to be updated, plus manage lastUpdate/thisUpdate
  95. ** so that they apply to the next update. */
  96.  
  97. void    InvalLayer(LayerObj theLayer, Rect invalRect, Boolean includeLastUpdate);
  98. /* Post a layer update rect.  The rect is unioned into the thisUpdate for the
  99. ** layer and all layers below this layer.  If includeLastUpdate is true, then
  100. ** the field includeLastUpdate is set true for each layer, as well.  This boolean
  101. ** is used by the default update behavior to determine if the area last updated
  102. ** should be updated again.  This makes animation effects easier in the the old
  103. ** and new position for a player being moved are updated at the same time.  This
  104. ** could be handled by hand by calculating the rect to be updated to include the
  105. ** last position, but by passing includeLastUpdate as true, it is
  106. ** handled automatically. */
  107.  
  108. OSErr    DefaultLayerProc(LayerObj theLayer, short message);
  109. /* The three currently defined message definitions are:
  110. **
  111. ** kLayerInit:     Called by NewLayer.  If layerPort is nil (which was
  112. **                 initialized by NewLayer), then the size/depth of the GWorld
  113. **                 that is created is dependent on aboveLayer.  If there is no
  114. **                 aboveLayer, this is an error, and paramErr is returned.
  115. **                 If the GWorld is successfully created, then layerOwnsPort is
  116. **                 set true.
  117. ** kLayerDispose:  Called when a layer is disposed of by either DisposeLayer or
  118. **                 DisposeThisAndBelowLayers.  It disposes of the GWorld if the
  119. **                 GWorld is owned by the layer.
  120. ** kLayerUpdate:   If there is a below layer, kLayerUpdate does a CopyBits from the
  121. **                 below layer into the current layer.  The copy is done from the
  122. **                 below layer's effectiveSrcRect into the current layer's
  123. **                 effectiveDstRect.  The transfer mode used is in xferMode, which
  124. **                 by default is srcCopy. */
  125.  
  126. Rect    GetEffectiveSrcRect(LayerObj theLayer);
  127. /* The effectiveSrcRect is srcRect or portRect of the layer.  If there is no srcRect,
  128. ** (srcRect is empty), then effectiveSrcRect is the layer's portRect. */
  129.  
  130. Rect    GetEffectiveDstRect(LayerObj theLayer);
  131. /* The effectiveDstRect is dstRect or portRect of the layer.  If there is no dstRect,
  132. ** (dstRect is empty), then effectiveDstRect is the layer's portRect. */
  133.  
  134. void    SetLayerWorld(LayerObj theLayer);
  135. /* This is a convenient call for setting a GWorld, while remembering what
  136. ** the previous GWorld was.  This should be balanced with a call to
  137. ** ResetLayerWorld.  A count of how many times this is called is kept
  138. ** so that the old GWorld is cached only if SetLayerWorld is currently
  139. ** in balance with ResetLayerWorld.  This keeps the oldest kept GWorld
  140. ** from being overwritten by subsequent calls. */
  141.  
  142. void    ResetLayerWorld(LayerObj theLayer);
  143. /* This is used to undo a call to SetLayerWorld.  Calls to ResetLayerWorld
  144. ** should be balanced with previous calls to SetLayerWorld. */
  145.  
  146. void    LockLayerWorld(LayerObj theLayer);
  147. /* This is a convenient way to lock down the pixels for a layer's GWorld.
  148. ** A locked count is kept to make sure that the GWorld is locked only the
  149. ** first time this is called.  Calls to LockLayerWorld will most likely
  150. ** be balanced by calls to UnlockLayerWorld, but not necessarily.  It may
  151. ** be desirable to keep a GWorld layer locked.  In this case, right after
  152. ** creating the layer (and indirectly its GWorld), call LockLayerWorld.
  153. ** This will initially lock it.  Subsequent calls would be balanced, and
  154. ** therefore there will always be one more LockLayerWorld call than
  155. ** UnlockLayerWorld calls.  This will keep it locked. */
  156.  
  157. void    UnlockLayerWorld(LayerObj theLayer);
  158. /* This undoes what LockLayerWorld does.  Calls to UnlockLayerWorld will
  159. ** generally be balanced with calls to LockLayerWorld. */
  160.  
  161. RgnHandle    ScreenDepthRegion(short depth);
  162.  
  163. CIconHandle    ReadCIcon(short iconID);
  164. void        KillCIcon(CIconHandle icon);
  165. void        DrawCIcon(CIconHandle icon, Rect destRect);
  166. void        DrawCIconNoMask(CIconHandle icon, Rect destRect);
  167. void        DrawCIconByDepth(CIconHandle icon, Rect destRect, short depth, Boolean useMask);
  168.  
  169.  
  170. #endif __GWLAYERS__
  171.